class HitTestPoint extends egret.DisplayObjectContainer {
    private ball: Ball

    private accurate: boolean = true
    private touchX: number
    private touchY: number

    public constructor() {
        super()
        this.once(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this)
    }

    private onAddToStage(): void {
        this.ball = new Ball()
        this.ball.x = this.stage.stageWidth / 2
        this.ball.y = this.stage.stageHeight / 2
        this.addChild(this.ball)
        this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.trackTouch, this)
        this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this)
    }

    private onEnterFrame() {
        if (this.ball.hitTestPoint(this.touchX, this.touchY, this.accurate)) {
            console.log("HIT")
        }
    }

    private trackTouch(evt:egret.TouchEvent) {
        this.touchX = evt.stageX
        this.touchY = evt.stageY
    }
}